﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class per_tx_records : MpageBase
{
    protected List<Model.SF_user_acc_cash> userOrder = null;
    protected Model.UsersAccount user_account = null;
    protected Model.CMember CMember = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        Bind();
        bindtable();
    }
    private void Bind()
    {
        if (loginUserInfo != null && loginUserInfo.Id > 0)
        {
            user_account = BLL.UsersAccount.GetModelByuser_id(loginUserInfo.Id);
            CMember = BLL.CMember.GetModel(loginUserInfo.Id);
            if (user_account == null)
            {
                BLL.Session.Remove(BLL.CMember.LoginUserSessionKey);
                Response.Redirect("/default.aspx");
            }
        }
        else
        {
            Response.Redirect("/default.aspx");
        }
    } 
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindtable();
    }
    protected void bindtable()
    {
        PagedDataSource pds = new PagedDataSource();
        int times = int.Parse(this.timesl.SelectedValue.ToString());
        string where = "";
        if (times == 0)
        {
            where = " and DateDiff(dd,addtime,getdate())=0";
        }
        else if (times == 1)
        {
            where = " and datediff(month,addtime,getdate())=0";
        }
        else if (times == 2)
        {
            where = " and datediff(week,addtime,getdate())=0 ";
        }
        else if (times == 3)
        {
            where = " and datediff(Month,addtime,getdate()) <=3 and datediff(Month,addtime,getdate()) >=0";
        }
        else if (times == 4)
        {
            where = " and datediff(Month,addtime,getdate()) <=6 and datediff(Month,addtime,getdate()) >=0";
        }
        string sql = "user_id=" + loginUserInfo.Id + "  " + where;
        int totalCount = 0;
        userOrder = BLL.SF_user_acc_cash.GetPageListBysql(this.AspNetPager1.CurrentPageIndex - 1, this.AspNetPager1.PageSize, sql, out totalCount);
        if (userOrder != null && userOrder.Count > 0)
        {
            AspNetPager1.Visible = true;
            AspNetPager1.RecordCount = totalCount;
            pds.AllowPaging = true;
            pds.PageSize = AspNetPager1.PageSize;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

        }
        else
        {
            AspNetPager1.Visible = false;
        }
    }
    protected void timesl_SelectedIndexChanged(object sender, EventArgs e)
    {
        Bind();
        bindtable();
    }
}